﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Q7.BevTree
{
    public class BevNodePreconditionOR : BevNodePrecondition
    {
        private BevNodePrecondition[] _list;

        public BevNodePreconditionOR(List<BevNodePrecondition> rest)
        {
            int len = rest.Count;
            if (len < 2)
                throw new ArgumentException("Invalid arguments!");

            _list = new BevNodePrecondition[len];
            for (var i = 0; i < len; i++)
                _list[i] = rest[i];
        }


        public override bool Evaluate(BevNodeInputParam input)
        {
            for (int i = 0, n = _list.Length; i < n; i++)
                if (_list[i].Evaluate(input))
                    return true;

            return false;
        }
    }
}
